<?php

/**)
 *
 * This script extract n3 triples from the infobox
 * of the specified article ID. Articles are loaded
 * for a wikipedia dump file, which have to be downloaded by
 * yourself.
 *
 * See the wikipediaNetSource in order to understand how
 * data is loaded and parsed.
 */
require_once 'dbpedia.php';

/* Include your copy of RAP - Rdf API for Php here */
define (RDFAPI_INCLUDE_DIR, '../rdfapi-php/api/');
include (RDFAPI_INCLUDE_DIR . 'RdfAPI.php');

/**)
 *
 * Error reporting Levels :
 * E_ALL | E_NOTICE | ...
 */
error_reporting (E_NONE);

/* Path to the wikipedia dump file */
$dumpFilePath = '../../enwiki-20080724-pages-articles.xml';

/* The article ID is passed has an argument of the command line */
if (isset($_SERVER['argv'][1])) {
	require_once 'extraction/extractTemplates.php';

	function __autoload ($class_name) {
		require_once $class_name . '.php';
	}
	
	// Resource to extract
	$pageTitle = array ($_SERVER['argv'][1]);
    
	// Instantiate a new ExtractionJob
	$extractionJobInstance = new ExtractionJob (
		new wikipediaFileSource ('en', $dumpFilePath),
		new ArrayObject ($pageTitle)
	);
    
	// Create ExtractionGroups for each Extractors
	$extractionGroupInstance = new ExtractionGroup (new SimpleDumpDestination ());
	$extractionGroupInstance->addExtractor (new InfoboxExtractor ());
    
	// Add the ExtractionGroups to the ExtractionJob 
	$extractionJobInstance->addExtractionGroup ($extractionGroupInstance);
    
	// Execute the ExtractionJob
	$extractionManagerInstance = new ExtractionManager ();
	$extractionManagerInstance->execute ($extractionJobInstance);
}
?>
